
<script src="web/assets/plugins/bootstrap-select2/select2.min.js" type="text/javascript"></script>
<script src="web/assets/plugins/jquery-datatable/js/jquery.dataTables.min.js" type="text/javascript" ></script>
<script src="web/assets/js/table_configuracion.js" type="text/javascript"></script>
<script src="./fuentes/view/ciudad/js/script_ajax_ciudad.js" type="text/javascript"></script>

<div class="clearfix"></div>
<div class="content">  

    <!-- Modal -->
    <div class="modal fade" id="myModalCiudadADD" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <br>
                    <i class="icon-credit-card icon-7x"></i>
                    <h4 id="myModalLabel" class="semi-bold">Ciudad</h4>
                    <p class="no-margin"> </p>
                    <br>
                </div>

                <div class="modal-body">
                    <form  action="./fuentes/controller/Ciudad.php" id="formCiudad" name="formCiudad" autocomplete="off" > 
                        <?php require_once '/FormCiudad.php'; ?>

                    </form>    
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
    </div>

    <div class="row" id="movimiento">
        <div class="col-md-12">
            <div class="grid simple ">
                <div class="grid-title no-border">
                    <h4><span class="semi-bold">Listado de Ciudades</span></h4>
                    <button style="float: right;" class="btn btn-success btn-xs " id="agregar" data-toggle="modal"  data-target="#myModalCiudadADD"> Agregar</button>
                    <span style="float:right;">
                        <input type="hidden" name="tipoListado"  id="tipoListado"  class="form-control" value="<?php echo $tipoListado; ?>" >
                        <select class="form-control" id="cmbTipoListado" name="cmbTipoListado">
                            <?php
                            if ($paises) {
                                if ($tipoListado == "ALL") {
                                    echo "<option selected value='TODOS'>TODOS</option>";
                                } else {
                                    echo "<option  value='TODOS'>TODOS</option>";
                                }
                                foreach ($paises as $datoC) {
                                    if ($tipoListado == $datoC["id"]) {
                                        echo " <option  value='" . $datoC["id"] . "'  selected='true'  >" . $datoC["nombre"] . "</option>";
                                    } else {
                                        echo " <option  value='" . $datoC["id"] . "'>" . $datoC["nombre"] . "</option>";
                                    }
                                }
                            }
                            ?>

                        </select>
                    </span>
                    <div class="labelRight" id="error">	
                    </div>
                </div>
                <div class="grid-body no-border">



                    <table class="table table-hover no-more-tables table-condensed  " id="ciudadTABLE">
                        <thead>
                            <tr>
                                <th style="width:1%;">ID</th>
                                <th style="width:15%;">Nombre </th>
                                <th style="width:4%;">Pais</th>
                                <th class='text-center' style="width:7%;">Accion</th>
                            </tr>
                        </thead>
                        <tbody id="ciudadList">
                            <?php
                            if ($ciudades) {
                                foreach ($ciudades as $dato) {
                                    echo "<tr>"
                                    . "<td>" . $dato["id"] . "</td>"
                                    . "<td>" . ($dato["nombre"]) . "</td>";
                                    foreach ($paises as $datoS) {
                                        if ($dato["pais_id"] == $datoS["id"]) {
                                            echo "<td>" . $datoS["nombre"] . "</td>";
                                        }
                                    }
                                    echo "<td class='text-center'>
                                        <button class='btn btn-success btn-xs btn-mini' onclick='editDatos(" . $dato["id"] . ")' title='Editar' ><i class='fa fa-pencil'></i></button>
                                        <button class='btn btn-success btn-xs btn-mini' onclick='eliminarDato(" . $dato["id"] . ")' title='Eliminar' ><i class='fa fa-times'></i></button>"
                                    . "</td>"
                                    . "</tr>";
                                }
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
